﻿using System;
using System.Diagnostics;
using System.Threading;

namespace EasyConveyor.TestClient
{
	internal sealed class RapidStep3Middleware : IMiddleware
	{
		private static readonly Random _random = new Random();

		public void Initialize()
		{
		}

		public bool Run(object context)
		{
			Debug.WriteLine("Rapid Step 3");
			var rapidContext = context as RapidContext;
			if (rapidContext == null)
			{
				Console.ForegroundColor = ConsoleColor.Red;
				Console.WriteLine("BIG PROBLEM!!!");
				Console.ReadKey();
				return false;
			}

			rapidContext.Step3 = true;
			Thread.Sleep(_random.Next(1, 1000));
			return true;
		}
	}
}
